package eleventh.System类;

public class 计算一个程序的执行时间{
    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        int sum  =0;
        for (int i = 0; i <2000000000 ; i++) {
            sum+=i;
        }
        long endTime=  System.currentTimeMillis();
        System.out.println("计算所花费的时间是："+(endTime-startTime)+"毫秒");
    }
}
/*
D:\WorkSpaces\Java\jdk-21\bin\java.exe "-javaagent:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\lib\idea_rt.jar=53643:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath D:\WorkSpaces\JavaDevelopBase_start_329\out\production\JavaDevelopBase_start_329 eleventh.System类.计算一个程序的执行时间
计算所花费的时间是：2毫秒

Process finished with exit code 0
 */